<?php
	include('header.php');
	
	if(!isset($user)) header('Location: index.php');

	if(isset($_POST['form_edit_mail'])){

	
		if(empty($_POST['form_edit_mail_email'])){
			$error = 0;
		}
		if(!isset($error) && !Tools::checkMail($_POST['form_edit_mail_email'])){
			$error = 1;
		}
		if(!isset($error)){
			$user->changeEmail($_POST['form_edit_mail_email']);
		}
	}
	
	include(TPL_DIR . 'edit-mail.html');
	
	include('footer.php');
?>